package ge.testes;

import ge.escola.Disciplina;
import ge.escola.Sala;
import ge.util.Horario;
import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;


public class HorarioTest {
	private Horario hora;
	private Horario hora1;
	private Disciplina disciplina;
	
	@Before 
	public void SetUp() throws Exception{
		Sala sala = new Sala(123,25,"teste");
		Disciplina disciplina = new Disciplina("matematica",sala,40,"001");
		hora = new Horario("Segunda","08:00",1.0,disciplina);
		try{
			disciplina = null;
			hora1 = new Horario("Segunda","08:00",1.0,disciplina);
		}catch(Exception e){
			Assert.assertEquals("segunda - 08:00 as 09:00 | Disciplina: nao cadastrada | Sala: 0\n", hora1.toString());
		}
	}
	
	@Test 
	public void testaGets() throws Exception{
		
		Assert.assertEquals(8.0, hora.getHoraI());
		Assert.assertEquals("segunda", hora.getDia());
		Assert.assertEquals("segunda - 08:00 as 09:00 | Disciplina: matematica | Sala: 123\n", hora.toString());
		try {
			Horario hora2 = new Horario("domingo","08:50",1.0,disciplina);
			Assert.fail();
		} catch (Exception e) {
			Assert.assertEquals("Dia invalido", e.getMessage());
		}

	}
	
	@Test
	public void testaSet() throws Exception{
		hora.setDia("Terca");
		hora.setHoraI("10:00");
		Assert.assertEquals("terca - 10:00 as 11:00 | Disciplina: matematica | Sala: 123\n", hora.toString());
	}
	
	@Test
	public void testaEquals() throws Exception{
		Horario hora2 = new Horario("Segunda","08:00",1.0,disciplina);
		Assert.assertTrue(hora.equals(hora2));
	}
	
}